---------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\Users\sbstjp\OneDrive - Cardiff University\FinalHarvard\Appendix3.3.log
  log type:  text
 opened on:  12 May 2025, 17:52:31

. set maxvar 30000


. use "C:\Users\sbstjp\OneDrive - Cardiff University\BES2024_W29_Panel_v29.1.dta" // Fieldhouse, E., J. Green, 
> G. Evans, J. Mellon, C. Prosser, J. Bailey, R. de Geus, H. Schmitt, C. van der Eijk, J. Griffiths, & S. Perre
> tt. (2024) British Election Study Internet Panel Waves 1-29. DOI: 10.5255/UKDA-SN-8202-2// Accessed on March 
> 11 2025.

. 
. // Social justice scale
. * Clean "don't know" responses
. foreach var in cwTransW25 cwAuthorsW25 cwLanguageW25 cwTrainingW25 {
  2.     replace `var' = . if `var' == 9999
  3. }
(3,094 real changes made, 3,094 to missing)
(2,880 real changes made, 2,880 to missing)
(1,344 real changes made, 1,344 to missing)
(3,760 real changes made, 3,760 to missing)

. 
. *Reverse variable so social justice coded high
. foreach var in cwLanguageW25 cwTrainingW25 {
  2.     qui sum `var'
  3.     local max_value = r(max)
  4.     gen r`var' = `max_value' + 1 - `var'
  5. }
(89,662 missing values generated)
(92,078 missing values generated)

. 
. *Standardize items in the scale from 1-2 - this avoids 0, for reasons outlined in next step
. foreach var in cwTransW25 cwAuthorsW25 rcwLanguageW25 rcwTrainingW25 {
  2.     summarize `var'
  3.     gen s`var' = 1 + (`var' - r(min)) / (r(max) - r(min))
  4. }

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
  cwTransW25 |     27,313    1.904697    1.145835          1          5
(91,412 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
cwAuthorsW25 |     27,527      2.8613    1.104186          1          5
(91,198 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
rcwLangua~25 |     29,063    2.063586    1.083667          1          5
(89,662 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
rcwTraini~25 |     26,647     2.94611    1.228869          1          5
(92,078 missing values generated)

. 
. * Replace missing values with 0 for the specified variables - this is necessary as Stata doesn't add up missi
> ng values and means a 0-1 standardization scale isn't feasible as missing values would overlap with the scale
. foreach var in scwTransW25 scwAuthorsW25 srcwLanguageW25 srcwTrainingW25 {
  2.     replace `var' = 0 if missing(`var')
  3. }
(91,412 real changes made)
(91,198 real changes made)
(89,662 real changes made)
(92,078 real changes made)

. 
. * Initialize the total score and the count of non-zero responses
. gen total_scoreSJV = 0

. gen count_nonzeroSJV = 0

. 
. * Add each variable to the total scale score and count it if non-zero
. foreach var in scwTransW25 scwAuthorsW25 srcwLanguageW25 srcwTrainingW25 {
  2.     replace total_scoreSJV = total_scoreSJV + `var'
  3.     replace count_nonzeroSJV = count_nonzeroSJV + (`var' != 0)
  4. }
(27,313 real changes made)
(27,313 real changes made)
(27,527 real changes made)
(27,527 real changes made)
(29,063 real changes made)
(29,063 real changes made)
(26,647 real changes made)
(26,647 real changes made)

. 
. * Calculate the average score, avoiding division by zero
. gen socJusValues = .
(118,725 missing values generated)

. replace socJusValues = total_scoreSJV / count_nonzeroSJV if count_nonzeroSJV > 0
(29,861 real changes made)

. 
. // Liberalism scale reverse
. qui sum al_scaleW23 

. local max_value = r(max)

. gen reversed_al_scaleW23 = `max_value' - al_scaleW23
(92,326 missing values generated)

. 
. // LifeSatisfaction
. replace lifeSatW23=. if lifeSatW23==9999 
(182 real changes made, 182 to missing)

. 
. *Standardize lifesat from 1-2, so it's like other dependent variables in the book
. foreach var in lifeSatW23 {
  2.     summarize `var'
  3.     gen s`var' = 1 + (`var' - r(min)) / (r(max) - r(min))
  4. }

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
  lifeSatW23 |      7,493    6.231149    2.211509          0         10
(111,232 missing values generated)

. 
. rename slifeSatW23 LifeSat

. 
. //Demographics
. *Recode, delete missing values and rename
. replace p_gross_householdW23=. if inlist(p_gross_householdW23, 16, 17) 
(8,165 real changes made, 8,165 to missing)

. 
. gen ReligiousAtt=.
(118,725 missing values generated)

. replace ReligiousAtt=1 if churchAttendanceW23==6
(1,818 real changes made)

. replace ReligiousAtt=0 if inlist(churchAttendanceW23, 0, 1, 2, 3, 4, 5, 9998)
(27,098 real changes made)

. 
. rename gender FemaleGender

. 
. *Generate dummy variables
. gen Married=. 
(118,725 missing values generated)

. replace Married=1 if inlist(p_maritalW23, 1, 2)
(15,390 real changes made)

. replace Married=0 if inrange(p_maritalW23, 3, 8)
(15,005 real changes made)

. 
. gen Unemployed=. 
(118,725 missing values generated)

. replace Unemployed=1 if workingStatusW23==4
(581 real changes made)

. replace Unemployed=0 if inlist(workingStatusW23, 1, 2, 3)
(15,030 real changes made)

. 
. egen age_centered = mean(ageW23) 

. replace age_centered = ageW23 - age_centered
(118,725 real changes made, 87,776 to missing)

. gen age_centered_squared = age_centered^2
(87,776 missing values generated)

. 
. gen Graduate=.
(118,725 missing values generated)

. replace Graduate=0 if inrange(p_edlevelUniW23, 0, 3)
(14,547 real changes made)

. replace Graduate=1 if inrange(p_edlevelUniW23, 4, 5)
(12,130 real changes made)

. 
. //Standardize
. rename Age Age1

. egen Age = std(age_centered_squared)
(87,776 missing values generated)

. egen Income = std(p_gross_householdW23)
(96,071 missing values generated)

. egen LibValues = std(reversed_al_scaleW23) 
(92,326 missing values generated)

. egen SocJusValues = std(socJusValues) 
(88,864 missing values generated)

. 
. //Regressions
. regress LifeSat SocJusValues [pweight= wt_new_W23], robust 
(sum of wgt is 4,519.40898114556)

Linear regression                               Number of obs     =      4,699
                                                F(1, 4697)        =       0.04
                                                Prob > F          =     0.8444
                                                R-squared         =     0.0000
                                                Root MSE          =     .22946

------------------------------------------------------------------------------
             |               Robust
     LifeSat | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
SocJusValues |  -.0009166   .0046704    -0.20   0.844    -.0100727    .0082395
       _cons |   1.609789   .0042187   381.59   0.000     1.601519     1.61806
------------------------------------------------------------------------------

. eststo
(est1 stored)

. regress LifeSat SocJusValues Age FemaleGender Graduate Income Married ReligiousAtt Unemployed [pweight= wt_ne
> w_W23], robust 
(sum of wgt is 1,795.90319782545)

Linear regression                               Number of obs     =      1,558
                                                F(8, 1549)        =      11.43
                                                Prob > F          =     0.0000
                                                R-squared         =     0.0860
                                                Root MSE          =     .20672

------------------------------------------------------------------------------
             |               Robust
     LifeSat | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
SocJusValues |  -.0000331   .0072246    -0.00   0.996    -.0142041     .014138
         Age |   .0016281    .008894     0.18   0.855    -.0158173    .0190736
FemaleGender |    .030353   .0133184     2.28   0.023      .004229     .056477
    Graduate |  -.0094438   .0142232    -0.66   0.507    -.0373426    .0184551
      Income |   .0398024   .0072671     5.48   0.000      .025548    .0540568
     Married |   .0557969    .013904     4.01   0.000     .0285243    .0830696
ReligiousAtt |    .102649   .0242649     4.23   0.000     .0550534    .1502446
  Unemployed |  -.0886145    .042415    -2.09   0.037    -.1718115   -.0054176
       _cons |    1.52438    .026241    58.09   0.000     1.472908    1.575851
------------------------------------------------------------------------------

. eststo
(est2 stored)

. regress LifeSat LibValues [pweight= wt_new_W23], robust 
(sum of wgt is 6,286.28547594626)

Linear regression                               Number of obs     =      6,469
                                                F(1, 6467)        =       9.99
                                                Prob > F          =     0.0016
                                                R-squared         =     0.0026
                                                Root MSE          =     .22458

------------------------------------------------------------------------------
             |               Robust
     LifeSat | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
   LibValues |  -.0114808   .0036324    -3.16   0.002    -.0186015   -.0043601
       _cons |   1.609936   .0034651   464.61   0.000     1.603143    1.616729
------------------------------------------------------------------------------

. eststo
(est3 stored)

. regress LifeSat LibValues Age FemaleGender Graduate Income Married ReligiousAtt Unemployed [pweight= wt_new_W
> 23], robust 
(sum of wgt is 2,549.81142076968)

Linear regression                               Number of obs     =      2,207
                                                F(8, 2198)        =      16.76
                                                Prob > F          =     0.0000
                                                R-squared         =     0.0816
                                                Root MSE          =     .20297

------------------------------------------------------------------------------
             |               Robust
     LifeSat | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
   LibValues |  -.0026531   .0058008    -0.46   0.647    -.0140287    .0087225
         Age |   .0045018    .006375     0.71   0.480    -.0079998    .0170035
FemaleGender |   .0190972   .0106046     1.80   0.072    -.0016988    .0398933
    Graduate |  -.0165734   .0122338    -1.35   0.176    -.0405644    .0074175
      Income |   .0417209    .006056     6.89   0.000     .0298449    .0535969
     Married |   .0443427   .0116986     3.79   0.000     .0214012    .0672841
ReligiousAtt |   .1193109   .0191378     6.23   0.000     .0817809    .1568408
  Unemployed |  -.0913964   .0350863    -2.60   0.009    -.1602022   -.0225906
       _cons |   1.554575   .0194842    79.79   0.000     1.516365    1.592784
------------------------------------------------------------------------------

. eststo
(est4 stored)

. regress LifeSat SocJusValues LibValues Age FemaleGender Graduate Income Married ReligiousAtt Unemployed [pwei
> ght= wt_new_W23], robust 
(sum of wgt is 1,576.40819927799)

Linear regression                               Number of obs     =      1,373
                                                F(9, 1363)        =       9.42
                                                Prob > F          =     0.0000
                                                R-squared         =     0.0804
                                                Root MSE          =      .2062

------------------------------------------------------------------------------
             |               Robust
     LifeSat | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
SocJusValues |   .0082041   .0098323     0.83   0.404    -.0110839    .0274921
   LibValues |  -.0143968   .0096546    -1.49   0.136    -.0333363    .0045428
         Age |  -.0011812   .0094297    -0.13   0.900    -.0196795    .0173171
FemaleGender |   .0203943     .01485     1.37   0.170    -.0087371    .0495257
    Graduate |  -.0081154   .0154791    -0.52   0.600    -.0384808    .0222501
      Income |   .0449052   .0077804     5.77   0.000     .0296423    .0601681
     Married |   .0432792   .0149535     2.89   0.004     .0139449    .0726136
ReligiousAtt |   .1077014   .0248546     4.33   0.000      .058944    .1564587
  Unemployed |  -.0673264   .0446325    -1.51   0.132    -.1548822    .0202295
       _cons |   1.541574   .0287064    53.70   0.000     1.485261    1.597888
------------------------------------------------------------------------------

. eststo
(est5 stored)

. esttab

--------------------------------------------------------------------------------------------
                      (1)             (2)             (3)             (4)             (5)   
                  LifeSat         LifeSat         LifeSat         LifeSat         LifeSat   
--------------------------------------------------------------------------------------------
SocJusValues    -0.000917      -0.0000331                                         0.00820   
                  (-0.20)         (-0.00)                                          (0.83)   

Age                               0.00163                         0.00450        -0.00118   
                                   (0.18)                          (0.71)         (-0.13)   

FemaleGender                       0.0304*                         0.0191          0.0204   
                                   (2.28)                          (1.80)          (1.37)   

Graduate                         -0.00944                         -0.0166        -0.00812   
                                  (-0.66)                         (-1.35)         (-0.52)   

Income                             0.0398***                       0.0417***       0.0449***
                                   (5.48)                          (6.89)          (5.77)   

Married                            0.0558***                       0.0443***       0.0433** 
                                   (4.01)                          (3.79)          (2.89)   

ReligiousAtt                        0.103***                        0.119***        0.108***
                                   (4.23)                          (6.23)          (4.33)   

Unemployed                        -0.0886*                        -0.0914**       -0.0673   
                                  (-2.09)                         (-2.60)         (-1.51)   

LibValues                                         -0.0115**      -0.00265         -0.0144   
                                                  (-3.16)         (-0.46)         (-1.49)   

_cons               1.610***        1.524***        1.610***        1.555***        1.542***
                 (381.59)         (58.09)        (464.61)         (79.79)         (53.70)   
--------------------------------------------------------------------------------------------
N                    4699            1558            6469            2207            1373   
--------------------------------------------------------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

. 
. log close
      name:  <unnamed>
       log:  C:\Users\sbstjp\OneDrive - Cardiff University\FinalHarvard\Appendix3.3.log
  log type:  text
 closed on:  12 May 2025, 17:53:21
---------------------------------------------------------------------------------------------------------------
